﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DataAccessLogic;
using System.Data;

namespace BusinessLogic
{
    [Serializable]
    public class Part : Table
    {
        #region Fields
        private string _description;
        private string _number;
        private decimal _price;
        private int _quantity;
        #endregion

        #region Methods
        public bool Create()
        {
            try
            {
                this._id = PartDataAccess.Create(this);

                if (this._id != Guid.Empty)
                {
                    return true;
                }
            }
            catch
            {
                return false;
            }

            return false;
        }

        public static List<Part> GetAll()
        {
            return PartDataAccess.GetAll();
        }

        public static Part GetByID(Guid id)
        {
            return PartDataAccess.GetByID(id);
        } 

        public static DataTable SearchAll()
        {
            return PartDataAccess.SearchAll();
        }
        #endregion

        #region Fields
        public string Description
        {
            get
            {
                return _description;
            }
            set
            {
               _description = value;
            }
        }
        public string Number
        {
            get
            {
                return _number;
            }
            set
            {
                _number = value;
            }
        }
        public decimal Price
        {
            get
            {
                return _price;
            }
            set
            {
                _price = value;
            }
        }
        public int Quantity
        {
            get 
            {
                return _quantity;
            }
            set
            {
                _quantity = value;
            }
        }
        public decimal Total
        {
            get
            {
                decimal _total = 0.00M;

                _total = _quantity * _price;

                return _total;
            }
        }
        #endregion
    }
}